var http=require("http");
var fs=require("fs");
var path=require("path");
// var filePath=path.join(__dirname,"/"+process.argv[2]);
// fs.access(filePath,(err)=>{
//     // filePath=path.join(__dirname,"/fileReader3.js");
//     console.log(err)
// });
var filePath=path.join(__dirname,"/"+process.argv[2]);
if(process.argv[2]){
    fs.access(filePath,(err)=>{
        // filePath=path.join(__dirname,"/fileReader3.js");
        console.log(err);
    });
}else{
    filePath=path.join(__dirname,"/fileReader3.js");
}
http.createServer((req,res)=>{    
    var readable=fs.createReadStream(filePath);
    readable.pipe(res);
}).listen(8081);

console.log("server is listening 8081");